﻿#region "Copyright (C) Lenny Granovsky. 2005-2013"
//This program is free software distribute under the terms of the GNU General Public License as published by
//the Free Software Foundation. Please read AssemblyInfo.cs file for more information.
#endregion

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Web.Enhancements.Rest.Filters
{
    /// <summary>
    /// Interface that any Web REST filter must implement in order of being processed through REST service pipeline.
    /// </summary>
    public interface IWebRestFilter
    {
        /// <summary>
        /// Method that is called prior the REST service handler created. This allows to cancel the call at earlier stages. 
        /// </summary>
        /// <remarks>The session and list parameters are not available at this time.</remarks>
        /// <remarks>This method should be used wisely to consume as low as possible resources,
        /// and especially fast to allow IIS to have overall better performance.</remarks>
        /// <param name="httpContext">Current HTTP content.</param>
        /// <param name="serviceContext">Current REST service context.</param>
        void BeforeHandlerCreated(System.Web.HttpContext httpContext, IWebRestServiceContext serviceContext);

        /// <summary>
        /// Method that is called just prior the REST service method call.
        /// </summary>
        /// <param name="httpContext">Current HTTP content.</param>
        /// <param name="serviceContext">Current REST service context.</param>
        void BeforeMethodCall(System.Web.HttpContext httpContext, IWebRestServiceContext serviceContext);

        /// <summary>
        /// Method that is called just after the REST service method is completed.
        /// </summary>
        /// <param name="context">Current HTTP context.</param>
        /// <param name="returnValue">Value that is going to be returned by service.</param>
        void AfterMethodCall(System.Web.HttpContext context, ref object returnValue);
    }
}
